由 Spring IoC 容器管理的對象稱為 Bean 。Bean 是由 Spring IoC 容器實例化、組裝和管理的對象。應用 Annotation 可以將一個物件註冊成為 Bean。
使用 Annotation 的好處:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
@SpringBootApplication:
@Configuration、@EnableAutoConfiguration 和 @ComponentScan,是啟動 Spring Boot 應用的核心註解。@Configuration:
@Bean 方法。@ComponentScan:
@Component、@Service、@Repository 等註解的類別,通常在 @SpringBootApplication 中已隱式配置。@EnableAutoConfiguration:
@SpringBootApplication 中。@Component:
@Service:
@Component的一種,表示 Service 業務邏輯層的類別。@Repository:
@Component的一種,表示 Dao 資料存取層的類別,並且會自動處理資料庫例外。@Controller:
@Component的一種, 表示 Controller 端口控制層的類別,包含資料取得或是配合前端模板 Thymeleaf 等前端頁面呈現。@Autowired:
@Bean
@Value:
application.properties 或 application.yml 中獲取。<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
@RestController:
@Controller 和 @ResponseBody,表示這個類別是 RESTful Controller,方法返回的資料會直接轉換成 JSON 或 XML,用於純資料取得的 API 端口。@RequestMapping:
@GetMapping, @PostMapping, @PutMapping, @DeleteMapping 來指定 HTTP 方法。@PathVariable:
@RequestParam:
@RequestBody:
@ResponseBody:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
@Entity:
@Table:
@Id:
@GeneratedValue:
IDENTITY、SEQUENCE 等。@Column:
@Repository:
@Query:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
@Aspect:
@Before、@After、@Around:
@ExceptionHandler:
@Valid:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
@RequestBody 或 @RequestParam 搭配使用。Ref:
相關文章也會同步更新我的部落格,有興趣也可以在裡面找其他的技術分享跟資訊。